From 7a521ca53f8e16e5734441ecdf4d186cd6c8c1b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Thu, 12 Jun 2008 21:00:34 +0000 Subject: [PATCH] reindented code, documented BABL_ERROR. * docs/index-static.html.in: reindented code, documented BABL_ERROR. svn path=/trunk/; revision=327 --- ChangeLog | 4 +++ docs/index-static.html.in | 55 +++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index caaa899..b807741 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-06-12 Øyvind Kolås + + * docs/index-static.html.in: reindented code, documented BABL_ERROR. + 2008-06-12 Øyvind Kolås * AUTHORS: updated. diff --git a/docs/index-static.html.in b/docs/index-static.html.in index ec9d61f..b44fc0d 100644 --- a/docs/index-static.html.in +++ b/docs/index-static.html.in @@ -183,8 +183,10 @@ internal consistency is governed by reference conversions that operate on double (64 bit floating point values). The only color model created during BablCore bootstrap is RGBA (linear light RGB, - 0.0 - 1.0, with a linear 0.0 - 1.0 opacity channel) backed by - the double datatype. + 0.0 - 1.0, with a linear 0.0 - 1.0 opacity channel) backed by the + double datatype. Defined similarily to scRGB' using + 64bit floating point.

If babls conversion isn't fast enough, you can provide @@ -201,48 +203,51 @@

Usage

-

The simplest scenario for using babl is converting between linear - buffers represented by an existing BablPixelFormat. +

babl_process (babl_fish (source_format, destination_format),
+              source_buffer, destination_buffer,
+              pixel_count);
+ +

The processing operation that babl performs is copying including + conversions if needed between linear buffers containing the same count + of pixels, with different pixel formats.

+
const Babl *srgb            = babl_format ("R'G'B' u8");
 const Babl *lab             = babl_format ("CIE Lab float");
 const Babl *rgb_to_lab_fish = babl_fish ( srgb, lab);
-int width = 123, height = 581, pixel_count = width * height;
+
 float         *lab_buffer;
 unsigned char *srgb_buffer;
 
 srgb_buffer = malloc (pixel_count * srgb->format.bytes_per_pixel);
-
-/* load data into srgb_buffer */
-
 lab_buffer  = malloc (pixel_count * 3 * 4);
 
+...... load data into srgb_buffer .......
+
 babl_process (bablfish, srgb_buffer, lab_buffer, pixel_count);
 
-/* do operation in lab space */
-babl_process (babl_fish(lab, srgb),
-                lab_buffer, srgb_buffer, pixel_count);
+...... do operation in lab space ........ -/* the data has now been transformed back to srgb data */ +babl_process (babl_fish(lab, srgb), + lab_buffer, srgb_buffer, pixel_count); - +/* the data has now been transformed back to srgb data */

If the existing pixel formats are not sufficient for your conversion needs, new ones can be created on the fly. The constructor will provide the prior created one if duplicates are registered.

format = babl_format_new (babl_model ("R'G'B'"),
-                          babl_type ("u8"),
-                          babl_component ("B'"),
-                          babl_component ("G'"),
-                          babl_component ("R'"),
-                          NULL);
+>const Babl *format = babl_format_new (babl_model ("R'G'B'"), + babl_type ("u16"), + babl_component ("B'"), + babl_component ("G'"), + babl_component ("R'"), + NULL); -
babl_process (babl_fish (source_format, destination_format),
-              source_buffer, destination_buffer,
-              pixel_count);
+

Through the environment variable BABL_ERROR you can control + a speed/performance trade off that by default is set very low (0.000001) + values in the range 0.01-0.1 can provide reasonable preview performance + by allowing lower numerical accuracy

.

Vocabulary

-- 2.30.2